package com.carrier.springboot.common.vo;

/**
 * 
    * @ClassName: RestResponse
    * @Description: TODO(封装返回数据 网络参考)
    * @author Carrier
    * @date 2018年9月12日
    *
 */
public class RestResponse {

	private final static String RESP_SUCCESS = "SUCCESS";
	private final static String RESP_ERROR = "ERROR";

	public static <T> RestResult<T> responseOK() {
		return new RestResult<T>().setCode(RestCode.SUCCESS).setMsg(RESP_SUCCESS);
	}

	public static <T> RestResult<T> responseOK(T data) {
		return new RestResult<T>().setCode(RestCode.SUCCESS).setMsg(RESP_SUCCESS).setData(data);
	}

	public static <T> RestResult<T> responseError(String message) {
		return new RestResult<T>().setCode(RestCode.FAIL).setMsg(RESP_ERROR);
	}

	public static <T> RestResult<T> makeRsp(int code, String msg) {
		return new RestResult<T>().setCode(code).setMsg(msg);
	}
	
	public static <T> RestResult<T> makeRsp(int code, String msg, T data) {
		return new RestResult<T>().setCode(code).setMsg(msg).setData(data);
	}
}
